package com.yss.reportworld.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yss.common.core.annotation.EasyExcel;
import com.yss.common.core.utils.easyexecl.IntegerConverter;
import com.yss.common.core.xss.Xss;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.yss.common.core.web.domain.BaseEntity;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 表明细信息对象 report_world_table_detail
 *
 * @author yss
 * @date 2023-03-23
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("report_world_table_detail")
public class TableDetail extends BaseEntity {

    /**
     * 主键
     */
    @ExcelIgnore
    @TableId("ID")
    private String id;

    /**
     * 表主键
     */
    @ExcelIgnore
    @TableField("TABLE_ID")
    private String tableId;

    /**
     * 字段名称
     */
    @ExcelProperty(value = "字段名称")
    @TableField("COLUMN_NAME")
    @NotBlank(message = "字段名称不能为空")
    @Size(min = 0, max = 30, message = "字段名称长度不能超过30个字符")
    @Pattern(regexp = "^(?!_0-9)(?!.*?_$)[A-Z_0-9]{2,30}$", message = "字段名称必须以字母开头，且只能为（大写字母，数字，下滑线），不能已下划线和数字开头，不能已下划线结尾，长度在2到30之间!")
    private String columnName;

    /**
     * 字段中文名称
     */
    @ExcelProperty(value = "字段中文名称")
    @TableField("COLUMN_CHINESE_NAME")
    @NotBlank(message = "字段中文名称不能为空")
    @Size(min = 0, max = 200, message = "字段中文名称长度不能超过200个字符")
    private String columnChineseName;


    //明细页面显示
    @ExcelProperty(value = "表中文名")
    @TableField(exist = false)
    private String tableChineseName;

    @ExcelProperty(value = "表名")
    @TableField(exist = false)
    private String tableName;

    /**
     * 字段类型
     */
    @ExcelProperty(value = "字段类型")
    @TableField("COLUMN_TYPE")
    private Integer columnType;

    /**
     * 字段长度
     */
    @ExcelProperty(value = "字段长度")
    @TableField("COLUMN_LENGTH")
    private Integer columnLength;

    /**
     * 小数位数
     */
    @ExcelProperty(value = "小数位数")
    @TableField("COLUMN_DECIMAL")
    private Integer columnDecimal;

    /**
     * 是否可为空
     */
    @ExcelProperty(value = "是否可为空", converter = IntegerConverter.class)
    @EasyExcel(readConverterExp = "1=是,2=否")
    @TableField("COLUMN_NULL")
    private Integer columnNull;

    /**
     * 默认值
     */
    @ExcelProperty(value = "默认值")
    @Xss(message = "默认值不能包含脚本字符")
    @TableField("COLUMN_DEFAULT")
    private String columnDefault;

    /**
     * 来源的字段
     */
    @ExcelProperty(value = "来源的字段")
    @TableField("ORIGINAL_COLUMN_NAME")
    private String originalColumnName;

    /**
     * 是否主键
     */
    @ExcelProperty(value = "是否主键", converter = IntegerConverter.class)
    @EasyExcel(readConverterExp = "1=是,2=否")
    @TableField("PRIMARY_KEY")
    private Integer primaryKey;

    /**
     * 是否业务主键
     */
    @ExcelProperty(value = "是否业务主键", converter = IntegerConverter.class)
    @EasyExcel(readConverterExp = "1=是,2=否")
    @TableField("BUSINESS_PRIMARY_KEY")
    private Integer businessPrimaryKey;

    /**
     * 外键对应的表名
     */
    @ExcelProperty(value = "外键对应的表名")
    @TableField("FOREIGN_TABLE")
    private String foreignTable;

    /**
     * 外键对应表字段
     */
    @ExcelProperty(value = "外键对应表字段")
    @TableField("FOREIGN_TABLE_COLUMN")
    private String foreignTableColumn;

    /**
     * 字典编码
     */
    @ExcelProperty(value = "字典编码")
    @TableField("CODE_NAME")
    private String codeName;

    /**
     * 版本号
     */
    @ExcelProperty(value = "版本号")
    @TableField("VERSION")
    private String version;

    /**
     * 文件名称
     */
    @ExcelProperty(value = "文件名称")
    @TableField("FILE_NAME")
    private String fileName;

    /**
     * 字段顺序
     */
    @ExcelProperty(value = "字段顺序")
    @TableField("ORDER_NUM")
    private Integer orderNum;

    /**
     * 内容是否为中文 1 是2否
     */
    @ExcelProperty(value = "内容是否为中文", converter = IntegerConverter.class)
    @EasyExcel(readConverterExp = "1=是,2=否")
    @TableField("MATCHER_CHINESE_CONTENT")
    private Integer matcherChineseContent;

    /**
     * 状态
     */
    @ExcelProperty(value = "状态", converter = IntegerConverter.class)
    @EasyExcel(readConverterExp = "1=正常,2=停用")
    @TableField("STATUS")
    private Integer status;


    /**
     * 历史版本号
     */
    @ExcelIgnore
    @TableField(exist = false)
    private String hisVersion;


    //前台页面查询获取到的集合信息
    // 所属模块
    @ExcelIgnore
    @TableField(exist = false)
    private List<String> strModular;
    //所属客户
    @ExcelIgnore
    @TableField(exist = false)
    private List<String> strCustomer;
    //所属报表
    @ExcelIgnore
    @TableField(exist = false)
    private List<String> strReport;

    // 所属模块
    @ExcelIgnore
    @TableField(exist = false)
    private String strModularName;
    //所属客户
    @ExcelIgnore
    @TableField(exist = false)
    private String strCustomerName;
    //所属报表
    @ExcelIgnore
    @TableField(exist = false)
    private String strReportName;

    //一个表对应客户集合
    @ExcelIgnore
    @TableField(exist = false)
    private List<DataCustomer> listCustomer;
    //一个表对应模块集合
    @ExcelIgnore
    @TableField(exist = false)
    private List<DataModular> listModular;
    //一个表对应报表集合
    @ExcelIgnore
    @TableField(exist = false)
    private List<DataReport> listReport;

    @ExcelIgnore
    @TableField(exist = false)
    private Integer layered;

    // 批量修改时候编号集合
    @ExcelIgnore
    @TableField(exist = false)
    private List<String> idList;


    @ExcelIgnore
    @TableField(exist = false)
    private String strColumnNull;
    // 字段类型
    @ExcelIgnore
    @TableField(exist = false)
    private String strColumnType;


    // 批量修改
    @ExcelIgnore
    @TableField(exist = false)
    private boolean clearModular;
    @ExcelIgnore
    @TableField(exist = false)
    private boolean clearCustomer;
    @ExcelIgnore
    @TableField(exist = false)
    private boolean clearReport;

    // 导出的时候选择 数据的主键
    @ExcelIgnore
    @TableField(exist = false)
    private String ids;
}
